import 'package:flutter/material.dart';
import 'package:flutter_pro_01/components/shop_list.dart';

class MyApp15 extends StatelessWidget {
  const MyApp15({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('ListView的Builder使用'),
        backgroundColor: const Color.fromARGB(255, 232, 221, 10),
      ),
      body: Container(
        padding: EdgeInsets.all(10),
        // 场景：适用于列表子组件比较多，而且子组件样式都一样的情况
        child: ListView.separated(
          itemBuilder: (BuildContext context, int index) {
            return ShopList();
          },
          // 便于划分割线
          separatorBuilder: (BuildContext context, int index) {
            return Divider(color: Colors.red, height: 1);
          },
          itemCount: 20,
        ),
      ),
    );
  }
}
